package com.fufan.mtsaas.modules.home.controller;

import com.fufan.mtsaas.modules.base.sysmsg.bo.request.MsgQueryRequest;
import com.fufan.mtsaas.modules.base.sysmsg.bo.response.MsgResponse;
import com.fufan.mtsaas.modules.base.sysmsg.service.TSysMessageService;
import com.fufan.mtsaas.modules.common.bo.request.DataRequestT;
import com.fufan.mtsaas.modules.common.bo.request.ResultPack;
import com.fufan.mtsaas.modules.common.bo.response.RequestPojo;
import com.fufan.mtsaas.modules.common.bo.response.Result;
import com.fufan.mtsaas.modules.home.bo.request.HomeQueryRequest;
import com.fufan.mtsaas.modules.home.bo.response.HomeMyApply;
import com.fufan.mtsaas.modules.home.bo.response.HomeSysMessage;
import com.fufan.mtsaas.modules.home.bo.response.HomeTotal;
import com.fufan.mtsaas.modules.home.service.HomeService;
import com.fufan.mtsaas.util.ParamUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@Api(tags = "MTSaas：主页面", description = "对象接口")
@RestController
@RequestMapping("/MTSaas/home")
public class HomeController {

    @Autowired
    private HomeService homeService;

    /**
     * 服务对象
     */
    @Resource
    private TSysMessageService targetService;

    @ApiOperation(value = "首页统计", httpMethod = "POST", produces = "application/json")
    @PostMapping(value = "/total")
    public Result<HomeTotal> total() {
//        XjsYearAuditQueryRequest mapData = dataRequest.getData().getParam();
        RequestPojo requestPojo = ParamUtil.doChange();
        return homeService.total();
    }
    @ApiOperation(value = "首页--我上报的列表", httpMethod = "POST", produces = "application/json")
    @PostMapping(value = "/myApply")
    public Result<HomeMyApply> myApply(@RequestBody DataRequestT<HomeQueryRequest> dataRequest) {
        HomeQueryRequest mapData = dataRequest.getData().getParam();
        RequestPojo requestPojo = ParamUtil.doChange();
        return homeService.myApply(mapData);
    }
    @ApiOperation(value = "首页--待审批列表", httpMethod = "POST", produces = "application/json")
    @PostMapping(value = "/noAuditList")
    public Result<HomeMyApply> noAuditList(@RequestBody DataRequestT<HomeQueryRequest> dataRequest) {
        HomeQueryRequest mapData = dataRequest.getData().getParam();
        RequestPojo requestPojo = ParamUtil.doChange();
        return homeService.noAuditList(mapData);
    }

//    @ApiOperation(value = "首页--消息列表", httpMethod = "POST", produces = "application/json")
//    @PostMapping(value = "sysMessageList")
//    public Result<HomeSysMessage> sysMessageList() {
////        XjsYearAuditQueryRequest mapData = dataRequest.getData().getParam();
//        RequestPojo requestPojo = ParamUtil.doChange();
//        return homeService.sysMessageList();
//    }

    /**
     * 首页--消息列表
     */
    @ApiOperation(value = "首页--消息列表", httpMethod = "POST", produces = "application/json")
    @PostMapping(value = "/sysMessageList")
    public Result<MsgResponse> sysMessageList(@RequestBody DataRequestT<MsgQueryRequest> dataRequest) {
        ResultPack resultPack = new ResultPack();
        RequestPojo requestPojo = ParamUtil.doChange();
        MsgQueryRequest mapdata = dataRequest.getData().getParam();

        return resultPack.doResultPack(targetService.doQueryPage(mapdata), requestPojo.getIntfId(), requestPojo.getAppKey());
    }
}
